<template>
<div class="box">
    <h1>子传父理论</h1>
    <div>name:{{ name  }}</div>
    <button @click="changeName('尹清林')">尹清林</button>

    <!-- 子传父：子组件通过$emit触发了自定义事件，父组件绑定自定义事件 -->
    <v-child @cname="changeName('孙悟空')" @cparent="changeName($event)" @dchange="changeName"></v-child>
</div>
</template>

<script>
import vChild from './vChild.vue';
export default {
    data(){
        return {
            name:"张浩天"
        }
    },
    methods:{
        changeName(n){
            console.log(n);
            this.name = n;
        }
    },
    components:{
        vChild
    }
}
</script>

<style>

</style>